﻿@using VideoSeller.Business.Data.Enums
@model AdminFundsViewModel

@{
	ViewBag.Title = @Html.GetGlobalResource("PagesTitles", "AdminFundsReport");
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<h2>@Html.GetGlobalResource("PagesTitles", "AdminFundsReport")</h2>

@using (Html.BeginForm("FundsReport", "Admin", FormMethod.Get)) {
	<label>@Html.GetLocalResource("PeriodFrom") </label>
	@Html.TextBoxFor(x => x.StartDate)<label> @Html.GetLocalResource("PeriodTo") </label>
	@Html.TextBoxFor(x => x.EndDate)
	<input type="submit" value="@Html.GetLocalResource("Apply")"/>
	<br/>
	<br/>
}

<label>@Html.GetLocalResource("TotalMoney") </label>&nbsp;@string.Format("{0:0}", Model.TotalMoney)<br/>
<label>@Html.GetLocalResource("TotalViews") </label>&nbsp;@string.Format("{0:0}", Model.TotalViews)<br/><br/>

<table>
	<tr>
		<th>@Html.GetLocalResource("Content")</th>
		<th>@Html.GetGlobalResource("AdminCommon", "SortBy") <a href="@Url.Action("FundsReport", "Admin", new {startDate = Model.StartDate, endDate = Model.EndDate, money = Model.SortByMoney.HasValue && Model.SortByMoney.Value == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending})">@Html.GetGlobalResource("AdminCommon", "MoneySort")</a> | 
			<a href="@Url.Action("FundsReport", "Admin", new {startDate = Model.StartDate, endDate = Model.EndDate, views = Model.SortByViews.HasValue && Model.SortByViews.Value == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending})">@Html.GetGlobalResource("AdminCommon", "Views")</a></th>
	</tr>
	@foreach (var item in Model.Items) {
		<tr>
			<td>
				<a href="@Url.Action("Content", "Home", new { id = item.OnlineContentId })" target="_blank">
					<img src="@Url.GetThumbnailImage(item.ImageUrl, ThumbnailImageSize.Small)" style="width: 200px; height: 100px;"/>
				</a><br/>
			</td>
			<td>
				<label>@Html.GetLocalResource("Money")&nbsp;&nbsp; @string.Format("{0:0}", item.Money)</label><br/>
				<label>@Html.GetLocalResource("Views")&nbsp;&nbsp; @item.Views</label><br/>
			</td>
		</tr>
	}
</table>

@if (Model.FilterViewModel.Total > 50) {
	<ul class="paging">
		@Html.Paging(Model.FilterViewModel.PageNumber, Model.FilterViewModel.PageCount, x => Url.Action(Model.FilterViewModel.Action, Model.FilterViewModel.Controller, new
		{
			page = x,
			startDate = Model.StartDate,
			endDate = Model.EndDate,
			money = Model.SortByMoney,
			views = Model.SortByViews,
		}))
	</ul>
	<div class="ui-helper-clearfix"></div><br/>
}